/*
	Copyright (c) 2010 Canadensys
*/
package net.canadensys.dataportal.vascan.utils;

import net.canadensys.dataportal.vascan.config.ApplicationConfig;

/**
 * Class responsible for mapping ID with related labels
 */
public class LabelMappings {
	/**
	 * 
	 * @param distributionid
	 * @return a string representation af the Distribution status
	 */
	public static final String getDistributionLabel(int distributionid){
	    String label = "";
	    switch(distributionid){
	    
	        case ApplicationConfig.DISTRIBUTION_EPHEMERE :
	            label = ApplicationConfig.LABEL_DISTRIBUTION_EPHEMERAL;
	            break;
	            
	        case ApplicationConfig.DISTRIBUTION_EXCLUDED :
	            label = ApplicationConfig.LABEL_DISTRIBUTION_EXCLUDED;
	            break;
	            
	        case ApplicationConfig.DISTRIBUTION_EXTIRPATED:
	            label = ApplicationConfig.LABEL_DISTRIBUTION_EXTIRPATED;
	            break;
	            
	        case ApplicationConfig.DISTRIBUTION_INTRODUCED:
	            label = ApplicationConfig.LABEL_DISTRIBUTION_INTRODUCED;
	            break;
	            
	        case ApplicationConfig.DISTRIBUTION_ABSENT:
	            label = ApplicationConfig.LABEL_DISTRIBUTION_ABSENT;
	            break;
	            
	        case ApplicationConfig.DISTRIBUTION_NATIVE:
	            label = ApplicationConfig.LABEL_DISTRIBUTION_NATIVE;
	            break;
	            
	        case ApplicationConfig.DISTRIBUTION_DOUBTFUL:
	            label = ApplicationConfig.LABEL_DISTRIBUTION_DOUBTFUL;
	            break;

	        default : 
	            label = ApplicationConfig.LABEL_DISTRIBUTION_ABSENT; 
	            break;  
	    }
	    return label;
	}

	/**
	 * 
	 * @param rankid
	 * @return a string representation of the Rank
	 */
	public static final String getRankLabel(int rankid){
	    String label = "";
	    switch(rankid){
	        case ApplicationConfig.RANK_ROOT:
	            label = ApplicationConfig.LABEL_RANK_ROOT;
	            break;

	        case ApplicationConfig.RANK_CLASS:
	            label = ApplicationConfig.LABEL_RANK_CLASS;
	            break;
	            
	        case ApplicationConfig.RANK_SUBCLASS:
	            label = ApplicationConfig.LABEL_RANK_SUBCLASS;
	            break;
	            
	        case ApplicationConfig.RANK_SUPERORDER:
	            label = ApplicationConfig.LABEL_RANK_SUPERORDER;
	            break;
	            
	        case ApplicationConfig.RANK_ORDER:
	            label = ApplicationConfig.LABEL_RANK_ORDER;
	            break;
	            
	        case ApplicationConfig.RANK_FAMILY:
	            label = ApplicationConfig.LABEL_RANK_FAMILY;
	            break;
	            
	        case ApplicationConfig.RANK_SUBFAMILY:
	            label = ApplicationConfig.LABEL_RANK_SUBFAMILY;
	            break;
	            
	        case ApplicationConfig.RANK_TRIBE:
	            label = ApplicationConfig.LABEL_RANK_TRIBE;
	            break;
	            
	        case ApplicationConfig.RANK_SUBTRIBE:
	            label = ApplicationConfig.LABEL_RANK_SUBTRIBE;
	            break;
	            
	        case ApplicationConfig.RANK_GENUS:
	            label = ApplicationConfig.LABEL_RANK_GENUS;
	            break;
	            
	        case ApplicationConfig.RANK_SUBGENUS:
	            label = ApplicationConfig.LABEL_RANK_SUBGENUS;
	            break;
	            
	        case ApplicationConfig.RANK_SECTION:
	            label = ApplicationConfig.LABEL_RANK_SECTION;
	            break;
	            
	        case ApplicationConfig.RANK_SUBSECTION:
	            label = ApplicationConfig.LABEL_RANK_SUBSECTION;
	            break;
	            
	        case ApplicationConfig.RANK_SERIES:
	            label = ApplicationConfig.LABEL_RANK_SERIES;
	            break;
	            
	        case ApplicationConfig.RANK_SPECIES:
	            label = ApplicationConfig.LABEL_RANK_SPECIES;
	            break;
	            
	        case ApplicationConfig.RANK_SUBSPECIES:
	            label = ApplicationConfig.LABEL_RANK_SUBSPECIES;
	            break;
	            
	        case ApplicationConfig.RANK_VARIETY:
	            label = ApplicationConfig.LABEL_RANK_VARIETY;
	            break;
	            
	        case ApplicationConfig.RANK_UNDEFINED:
	            label = ApplicationConfig.LABEL_RANK_UNDEFINED;
	            break;

	        default:
	            label = ApplicationConfig.LABEL_RANK_UNDEFINED;
	            break;
	    }
	    return label;
	}

	
	public static int getRankId(String rank){
		int rankid = 0;
		if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_CLASS.toLowerCase()))
			rankid = ApplicationConfig.RANK_CLASS;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_SUBCLASS.toLowerCase()))
			rankid = ApplicationConfig.RANK_SUBCLASS;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_SUPERORDER.toLowerCase()))
			rankid = ApplicationConfig.RANK_SUPERORDER;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_ORDER.toLowerCase()))
			rankid = ApplicationConfig.RANK_ORDER;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_FAMILY.toLowerCase()))
			rankid = ApplicationConfig.RANK_FAMILY;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_SUBFAMILY.toLowerCase()))
			rankid = ApplicationConfig.RANK_SUBFAMILY;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_TRIBE.toLowerCase()))
			rankid = ApplicationConfig.RANK_TRIBE;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_SUBTRIBE.toLowerCase()))
			rankid = ApplicationConfig.RANK_SUBTRIBE;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_GENUS.toLowerCase()))
			rankid = ApplicationConfig.RANK_GENUS;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_SUBGENUS.toLowerCase()))
			rankid = ApplicationConfig.RANK_SUBGENUS;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_SECTION.toLowerCase()))
			rankid = ApplicationConfig.RANK_SECTION;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_SUBSECTION.toLowerCase()))
			rankid = ApplicationConfig.RANK_SUBSECTION;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_SERIES.toLowerCase()))
			rankid = ApplicationConfig.RANK_SERIES;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_SPECIES.toLowerCase()))
			rankid = ApplicationConfig.RANK_SPECIES;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_SUBSPECIES.toLowerCase()))
			rankid = ApplicationConfig.RANK_SUBSPECIES;
		else if(rank.toLowerCase().equals(ApplicationConfig.LABEL_RANK_VARIETY.toLowerCase()))
			rankid = ApplicationConfig.RANK_VARIETY;
		else 
			rankid = ApplicationConfig.RANK_UNDEFINED;
	    return rankid;
	}
	
	/**
	 * 
	 * @param habitusid
	 * @return a string representation of the Habitus
	 */
	public static String getHabitusLabel(int habitusid){
	    String label = "";
	    switch(habitusid){
	    
	        case ApplicationConfig.HABITUS_NONE :
	            label = ApplicationConfig.LABEL_HABITUS_NONE;
	            break;
	            
	        case ApplicationConfig.HABITUS_HERB :
	            label = ApplicationConfig.LABEL_HABITUS_HERB;
	            break;
	            
	        case ApplicationConfig.HABITUS_SHRUB :
	            label = ApplicationConfig.LABEL_HABITUS_SHRUB;
	            break;
	            
	        case ApplicationConfig.HABITUS_TREE :
	            label = ApplicationConfig.LABEL_HABITUS_TREE;
	            break;
	            
	        case ApplicationConfig.HABITUS_VINE : 
	            label = ApplicationConfig.LABEL_HABITUS_VINE;
	            break;
	            
	        default : 
	            label = ApplicationConfig.LABEL_HABITUS_NONE; 
	            break;  
	    }
	    return label;
	}
	
	public static String getStatusLabel(int statusid){
	    String label = "";
	    switch(statusid){
	    
	        case ApplicationConfig.STATUS_ACCEPTED :
	            label = ApplicationConfig.LABEL_STATUS_ACCEPTED;
	            break;
	            
	        case ApplicationConfig.STATUS_SYNONYM :
	            label = ApplicationConfig.LABEL_STATUS_SYNONYM;
	            break;
	            
	        default : 
	            label = ApplicationConfig.LABEL_STATUS_ACCEPTED; 
	            break;  
	    }
	    return label;
	}
}
